package net.worthtech.callcasher;

import android.content.ComponentName;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AlertDialog;
import android.support.v7.app.AppCompatActivity;
import android.text.TextUtils;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;

import com.google.gson.Gson;

public class MainActivity extends AppCompatActivity {

    private android.widget.EditText et;
    private EditText returnTime;
    private android.widget.Button card;
    private String mMoney;
    private Button comsume;
    private Button refund;
    private Button info;
    private Button signnow;
    private String mOrder;
    private EditText etorder;
    private Button preauth;
    private Button guarantee;
    private String mToken;
    private Button preauthCancel;
    private Button preauthCom;
    private Button preauthComCancel;
    private Button sign;
    private EditText innermerid;
    private String mInnerMerid;
    private String mTrace;
    private String mAuthInfo;
    private Button wechatqr;
    private Button alipayqr;
    private Button unionqr;
    private EditText remark;
    private Button mSetting;
    private Button mClear;
    private Button mPhoneRefund;

    private String mPhoneOrder;
    private String mPhoneMoney;
    private Button wildCardPreauth;
    private Button wildCardConsume;
    private Button wildCardPreauthCom;
    private Button call4;
    private Button call5;
    private Button setting;
    private Button clear;
    private Button phoneRefund;
    private Button fenzhang;
    private Button reprintTicket;
    private Button cash;
    private Button d0;
    private Button invoice;
    private Button print;
    private Button phonePay;
    private Button cardRedund;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        LogUtils.i("MainActivity.onCreate:");
        setContentView(R.layout.activity_demo);
        this.returnTime = findViewById(R.id.returntime);
        this.phonePay = findViewById(R.id.phonePay);
        this.print = (Button) findViewById(R.id.print);
        this.invoice = (Button) findViewById(R.id.invoice);
        this.cash = (Button) findViewById(R.id.cash);
        this.reprintTicket = (Button) findViewById(R.id.reprintTicket);
        this.fenzhang = (Button) findViewById(R.id.fenzhang);
        this.phoneRefund = (Button) findViewById(R.id.phoneRefund);
        this.clear = (Button) findViewById(R.id.clear);
        this.setting = (Button) findViewById(R.id.setting);
        this.call5 = (Button) findViewById(R.id.call5);
        this.call4 = (Button) findViewById(R.id.call4);
        this.wildCardConsume = (Button) findViewById(R.id.wildCardConsume);
        this.wildCardPreauth = (Button) findViewById(R.id.wildCardPreauth);
        this.wildCardPreauthCom = (Button) findViewById(R.id.wildCardPreauthCom);
        mPhoneRefund = (Button) findViewById(R.id.phoneRefund);
        mSetting = (Button) findViewById(R.id.setting);
        mClear = (Button) findViewById(R.id.clear);
        this.remark = (EditText) findViewById(R.id.remark);
        this.unionqr = (Button) findViewById(R.id.unionqr);
        this.alipayqr = (Button) findViewById(R.id.alipayqr);
        this.wechatqr = (Button) findViewById(R.id.wechatqr);
        this.innermerid = (EditText) findViewById(R.id.innermerid);
        this.sign = (Button) findViewById(R.id.sign);
        this.preauthComCancel = (Button) findViewById(R.id.preauthComCancel);
        this.preauthCom = (Button) findViewById(R.id.preauthCom);
        this.preauthCancel = (Button) findViewById(R.id.preauthCancel);
        this.preauth = (Button) findViewById(R.id.preauth);
        this.guarantee = (Button) findViewById(R.id.guarantee);
        this.etorder = (EditText) findViewById(R.id.et_order);
        this.signnow = (Button) findViewById(R.id.call5);
        this.info = (Button) findViewById(R.id.call4);
        this.refund = (Button) findViewById(R.id.call3);
        this.comsume = (Button) findViewById(R.id.call2);
        this.card = (Button) findViewById(R.id.call);
        this.et = (EditText) findViewById(R.id.et);
        this.d0 = (Button) findViewById(R.id.d0);
        cardRedund = (Button) findViewById(R.id.cardRedund);

        cardRedund.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                startActivity(new Intent(MainActivity.this, CardRefundActivity.class));
            }
        });

        etorder.setText(String.valueOf(System.currentTimeMillis()));

        final String content = "{\n" +
                "\t\"list\":[\n" +
                "\t\t{\n" +
                "\t\t\t\"type\":1,\n" +
                "\t\t\t\"content\":\"这是标题\"\n" +
                "\t\t},\n" +
                "\t\t{\n" +
                "\t\t\t\"type\":2,\n" +
                "\t\t\t\"content\":\"这是文本\"\n" +
                "\t\t},\n" +
                "\t\t{\n" +
                "\t\t\t\"type\":4,\n" +
                "\t\t\t\"content\":\"12345678901234567\"\n" +
                "\t\t}\n" +
                "\t]\n" +
                "}";

        d0.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                mMoney = et.getText().toString();
                mInnerMerid = innermerid.getText().toString();
                Intent intent = new Intent();
                intent.setComponent(new ComponentName("net.worthtech.worthcasher",
                        "net.worthtech.worthcasher.activity.PayService"));
                intent.putExtra("option", "consume");
                intent.putExtra("amount", mMoney);
                intent.putExtra("paytype", "d0");
                if (mInnerMerid != null && mInnerMerid.length() != 0) {
                    intent.putExtra("clearIdentify", mInnerMerid);
                }
                mOrder = etorder.getText().toString();
                String strRemark = remark.getText().toString();
                intent.putExtra("remark", strRemark);
                intent.putExtra("orderNo", mOrder);
                startActivityForResult(intent, 0);
            }
        });

        phonePay.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                mMoney = et.getText().toString();
                mInnerMerid = innermerid.getText().toString();
                Intent intent = new Intent();
                intent.setComponent(new ComponentName("net.worthtech.worthcasher",
                        "net.worthtech.worthcasher.activity.PayService"));
                intent.putExtra("option", "consume");
                intent.putExtra("paytype", "phonePay");
//                intent.putExtra("optionpage", true);
                intent.putExtra("amount", mMoney);
                if (mInnerMerid != null && mInnerMerid.length() != 0) {
                    intent.putExtra("clearIdentify", mInnerMerid);
                }
                mOrder = etorder.getText().toString();
                String strRemark = remark.getText().toString();
                intent.putExtra("remark", strRemark);
                intent.putExtra("orderNo", mOrder);
                startActivityForResult(intent, 0);
            }
        });

        print.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent();
                intent.setComponent(new ComponentName("net.worthtech.worthcasher",
                        "net.worthtech.worthcasher.activity.PayService"));
                intent.putExtra("option", "print");
                intent.putExtra("content", content);
                startActivityForResult(intent, 5);
            }
        });

        invoice.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                mMoney = et.getText().toString();
                Intent intent = new Intent();
                intent.setComponent(new ComponentName("net.worthtech.worthcasher",
                        "net.worthtech.worthcasher.activity.PayService"));
                intent.putExtra("option", "invoice");
                intent.putExtra("amount", mMoney);
                mOrder = etorder.getText().toString();
                intent.putExtra("orderNo", mOrder);
                startActivityForResult(intent, 5);
            }
        });

        cash.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                mMoney = et.getText().toString();
                mInnerMerid = innermerid.getText().toString();
                Intent intent = new Intent();
                intent.setComponent(new ComponentName("net.worthtech.worthcasher",
                        "net.worthtech.worthcasher.activity.PayService"));
                intent.putExtra("option", "consume");
                intent.putExtra("paytype", "cash");
                intent.putExtra("amount", mMoney);
                if (mInnerMerid != null && mInnerMerid.length() != 0) {
                    intent.putExtra("clearIdentify", mInnerMerid);
                }
                mOrder = etorder.getText().toString();
                intent.putExtra("orderNo", mOrder);
                startActivityForResult(intent, 0);
            }
        });

        reprintTicket.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent();
                intent.setComponent(new ComponentName("net.worthtech.worthcasher",
                        "net.worthtech.worthcasher.activity.PayService"));
                intent.putExtra("option", "reprintTicket");
                intent.putExtra("trace", mTrace);
                startActivityForResult(intent, 7);
            }
        });

        mPhoneRefund.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent();
                intent.setComponent(new ComponentName("net.worthtech.worthcasher",
                        "net.worthtech.worthcasher.activity.PayService"));
                intent.putExtra("option", "phoneRefund");
                intent.putExtra("phoneOrder", mPhoneOrder);
                intent.putExtra("amount", mPhoneMoney);
                startActivityForResult(intent, 6);
            }
        });

        mClear.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent();
                intent.setComponent(new ComponentName("net.worthtech.worthcasher",
                        "net.worthtech.worthcasher.activity.PayService"));
                intent.putExtra("option", "clear");
                intent.putExtra("reprint", true);
                // 增加时间
                String time =  returnTime.getText().toString();
                if(TextUtils.isEmpty(time)) {

                }else if(TextUtils.isDigitsOnly(time)){
                    intent.putExtra("returntime", time);
                    //intent.putExtra("optionpage", true);
                }else {
                    //intent.putExtra("optionpage", true);
                }
                startActivityForResult(intent, 5);
            }
        });

        wechatqr.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                mMoney = et.getText().toString();
                mInnerMerid = innermerid.getText().toString();
                Intent intent = new Intent();
                intent.setComponent(new ComponentName("net.worthtech.worthcasher",
                        "net.worthtech.worthcasher.activity.PayService"));
                intent.putExtra("option", "consume");
                intent.putExtra("paytype", "wechat");
                intent.putExtra("amount", mMoney);
                if (mInnerMerid != null && mInnerMerid.length() != 0) {
                    intent.putExtra("clearIdentify", mInnerMerid);
                }
                mOrder = etorder.getText().toString();
                intent.putExtra("orderNo", mOrder);
                startActivityForResult(intent, 0);
            }
        });

        sign.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent();
                intent.setComponent(new ComponentName("net.worthtech.worthcasher",
                        "net.worthtech.worthcasher.activity.PayService"));
                intent.putExtra("option", "sign");
                startActivityForResult(intent, 5);
            }
        });

        mSetting.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent();
                intent.setComponent(new ComponentName("net.worthtech.worthcasher",
                        "net.worthtech.worthcasher.activity.ManageActivity"));
                intent.putExtra("option", "sign");
                startActivityForResult(intent, 6);
            }
        });

        comsume.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                mMoney = et.getText().toString();
                mInnerMerid = innermerid.getText().toString();
                Intent intent = new Intent();
                intent.setComponent(new ComponentName("net.worthtech.worthcasher",
                        "net.worthtech.worthcasher.activity.PayService"));
                intent.putExtra("option", "consume");
                intent.putExtra("amount", mMoney);
                if (mInnerMerid != null && mInnerMerid.length() != 0) {
                    intent.putExtra("clearIdentify", mInnerMerid);
                }
                mOrder = etorder.getText().toString();
                String strRemark = remark.getText().toString();
                intent.putExtra("remark", strRemark);
                intent.putExtra("orderNo", mOrder);

                // 增加时间
                String time =  returnTime.getText().toString();
                if(TextUtils.isEmpty(time)) {

                }else if(TextUtils.isDigitsOnly(time)){
                    intent.putExtra("returntime", time);
                    intent.putExtra("optionpage", true);
                }else {
                    intent.putExtra("optionpage", true);
                }

                startActivityForResult(intent, 0);
            }
        });

        card.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                mMoney = et.getText().toString();
                mInnerMerid = innermerid.getText().toString();
                Intent intent = new Intent();
                intent.setComponent(new ComponentName("net.worthtech.worthcasher",
                        "net.worthtech.worthcasher.activity.PayService"));
                intent.putExtra("option", "consume");
                intent.putExtra("amount", mMoney);
                if (mInnerMerid != null && mInnerMerid.length() != 0) {
                    intent.putExtra("clearIdentify", mInnerMerid);
                }
                // 增加时间
                String time =  returnTime.getText().toString();
                if(TextUtils.isEmpty(time)) {

                }else if(TextUtils.isDigitsOnly(time)){
                    intent.putExtra("returntime", time);
                    intent.putExtra("optionpage", true);
                }else {
                    intent.putExtra("optionpage", true);
                }
                intent.putExtra("paytype", "card");
                String strRemark = remark.getText().toString();
                intent.putExtra("remark", strRemark);
                mOrder = etorder.getText().toString();
                intent.putExtra("orderNo", mOrder);
                startActivityForResult(intent, 0);
            }
        });

        refund.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent();
                intent.setComponent(new ComponentName("net.worthtech.worthcasher",
                        "net.worthtech.worthcasher.activity.PayService"));
                intent.putExtra("option", "refund");
                intent.putExtra("refundTrace", mTrace);

                // 增加时间
                String time =  returnTime.getText().toString();
                if(TextUtils.isEmpty(time)) {

                }else if(TextUtils.isDigitsOnly(time)){
                    intent.putExtra("returntime", time);
                    //intent.putExtra("optionpage", true);
                }else {
                    //intent.putExtra("optionpage", true);
                }
                startActivityForResult(intent, 0);
            }
        });

        info.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent();
                intent.setComponent(new ComponentName("net.worthtech.worthcasher",
                        "net.worthtech.worthcasher.activity.PayService"));
                intent.putExtra("option", "getMerInfo");
                startActivityForResult(intent, 1);
            }
        });

        signnow.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent();
                intent.setComponent(new ComponentName("net.worthtech.worthcasher",
                        "net.worthtech.worthcasher.activity.PayService"));
                intent.putExtra("option", "check");
                intent.putExtra("orderNo", etorder.getText().toString());
                startActivityForResult(intent, 2);
            }
        });

        preauth.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                mMoney = et.getText().toString();
                Intent intent = new Intent();
                intent.setComponent(new ComponentName("net.worthtech.worthcasher",
                        "net.worthtech.worthcasher.activity.PayService"));
                intent.putExtra("option", "preauth");
                intent.putExtra("paytype", "card");
                intent.putExtra("amount", mMoney);
                mOrder = etorder.getText().toString();
                String strRemark = remark.getText().toString();
                intent.putExtra("remark", strRemark);
                intent.putExtra("orderNo", mOrder);
                startActivityForResult(intent, 0);
            }
        });

        guarantee.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                mMoney = et.getText().toString();
                Intent intent = new Intent();
                intent.setComponent(new ComponentName("net.worthtech.worthcasher",
                        "net.worthtech.worthcasher.activity.PayService"));
                intent.putExtra("option", "preauth");
                intent.putExtra("paytype", "phonePay");
                intent.putExtra("amount", mMoney);
                mOrder = etorder.getText().toString();
                String strRemark = remark.getText().toString();
                intent.putExtra("remark", strRemark);
                intent.putExtra("orderNo", mOrder);
                startActivityForResult(intent, 0);
            }
        });

        preauthCancel.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                mMoney = et.getText().toString();
                Intent intent = new Intent();
                intent.setComponent(new ComponentName("net.worthtech.worthcasher",
                        "net.worthtech.worthcasher.activity.PayService"));
                intent.putExtra("option", "preauthCancel");
                intent.putExtra("amount", mMoney);
                mOrder = etorder.getText().toString();
                intent.putExtra("authInfo", mAuthInfo);
                intent.putExtra("orderNo", mOrder);
                startActivityForResult(intent, 0);
            }
        });

        preauthCom.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                mMoney = et.getText().toString();
                Intent intent = new Intent();
                intent.setComponent(new ComponentName("net.worthtech.worthcasher",
                        "net.worthtech.worthcasher.activity.PayService"));
                intent.putExtra("option", "preauthCom");
                intent.putExtra("amount", mMoney);
                mOrder = etorder.getText().toString();
                intent.putExtra("authInfo", mAuthInfo);
                intent.putExtra("orderNo", mOrder);
                startActivityForResult(intent, 0);
            }
        });

        preauthComCancel.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                mMoney = et.getText().toString();
                Intent intent = new Intent();
                intent.setComponent(new ComponentName("net.worthtech.worthcasher",
                        "net.worthtech.worthcasher.activity.PayService"));
                intent.putExtra("option", "preauthComCancel");
                intent.putExtra("amount", mMoney);

                mOrder = etorder.getText().toString();
                intent.putExtra("refundTrace", mTrace);
                intent.putExtra("orderNo", mOrder);
                startActivityForResult(intent, 0);
            }
        });

        wildCardConsume.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                mMoney = et.getText().toString();
                mInnerMerid = innermerid.getText().toString();
                Intent intent = new Intent();
                intent.setComponent(new ComponentName("net.worthtech.worthcasher",
                        "net.worthtech.worthcasher.activity.PayService"));
                intent.putExtra("option", "wildCardConsume");
                intent.putExtra("amount", mMoney);
                if (mInnerMerid != null && mInnerMerid.length() != 0) {
                    intent.putExtra("clearIdentify", mInnerMerid);
                }
                mOrder = etorder.getText().toString();
                String strRemark = remark.getText().toString();
                intent.putExtra("remark", strRemark);
                intent.putExtra("orderNo", mOrder);
                startActivityForResult(intent, 0);
            }
        });

        wildCardPreauth.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                mMoney = et.getText().toString();
                Intent intent = new Intent();
                intent.setComponent(new ComponentName("net.worthtech.worthcasher",
                        "net.worthtech.worthcasher.activity.PayService"));
                intent.putExtra("option", "wildCardPreauth");
                intent.putExtra("paytype", "card");
                intent.putExtra("amount", mMoney);
                mOrder = etorder.getText().toString();
                String strRemark = remark.getText().toString();
                intent.putExtra("remark", strRemark);
                intent.putExtra("orderNo", mOrder);
                startActivityForResult(intent, 0);
            }
        });

        wildCardPreauthCom.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                mMoney = et.getText().toString();
                Intent intent = new Intent();
                intent.setComponent(new ComponentName("net.worthtech.worthcasher",
                        "net.worthtech.worthcasher.activity.PayService"));
                intent.putExtra("option", "wildCardPreauthCom");
                intent.putExtra("amount", mMoney);
                mOrder = etorder.getText().toString();
                intent.putExtra("authInfo", mAuthInfo);
                intent.putExtra("orderNo", mOrder);
                startActivityForResult(intent, 0);
            }
        });
    }

    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        Log.i("wurui", "MainActivity.onActivityResult:" + requestCode + "#" + resultCode + data);

        if (requestCode == 1) {
            String mer_name = data.getStringExtra("mer_name");
            String mer_id = data.getStringExtra("mer_id");
            String ter_id = data.getStringExtra("ter_id");
            LogUtils.i("MainActivity.onActivityResult->:" + mer_name + mer_id + ter_id);
        }

        if (requestCode == 2) {
            if (data == null) {
                Toast.makeText(this, "未查询", Toast.LENGTH_SHORT).show();
                return;
            }
            String result = data.getStringExtra("result");
            mTrace = data.getStringExtra("trace");
            mAuthInfo = data.getStringExtra("authInfo");
            String authProcess = data.getStringExtra("authProcess");
            Toast.makeText(this, etorder.getText().toString() + ":" + result +"\n" + "authProcess：" + authProcess, Toast.LENGTH_SHORT).show();
            LogUtils.i("MainActivity.onActivityResult.authProcess->:" + authProcess);
            LogUtils.i("MainActivity.onActivityResult->:" + data.getStringExtra("printInfo"));
        }

        if (requestCode == 3) {
            mToken = data.getStringExtra("token");
            LogUtils.i("MainActivity.onActivityResult->:" + mToken);
            String cardNo = data.getStringExtra("cardNo");
            LogUtils.i("MainActivity.onActivityResult->:" + cardNo);
            return;
        }

        if (requestCode == 4) {
            String printInfo = data.getStringExtra("printInfo");

            LogUtils.i("MainActivity.onActivityResult->:" + printInfo);
        }

        if (requestCode == 5) {
            String result = data.getStringExtra("result");
            LogUtils.i("MainActivity.onActivityResult->:" + result);
            if (result.equals("00")) {
                Toast.makeText(this, "签到成功", Toast.LENGTH_SHORT).show();
            }
        }

        if (requestCode == 6) {
            LogUtils.i("MainActivity.onActivityResult->:" + data.getStringExtra("result"));
            LogUtils.i("MainActivity.onActivityResult->:" + data.getStringExtra("paytype"));
            LogUtils.i("MainActivity.onActivityResult->:" + data.getStringExtra("trace"));
            LogUtils.i("MainActivity.onActivityResult->:" + data.getStringExtra("referenceNo"));
            LogUtils.i("MainActivity.onActivityResult->:" + data.getStringExtra("amount"));
            LogUtils.i("MainActivity.onActivityResult->:" + data.getStringExtra("authInfo"));
            LogUtils.i("MainActivity.onActivityResult->:" + data.getStringExtra("printInfo"));
        }

        if (requestCode == 7) {
            Toast.makeText(this, "重打印结果" + data.getStringExtra("result"), Toast.LENGTH_SHORT).show();
        }

        if (requestCode != 0) {
            return;
        }

        if (data != null) {
            LogUtils.i("MainActivity.onActivityResult->:" + data.getStringExtra("paytype"));
            LogUtils.i("MainActivity.onActivityResult->:" + data.getStringExtra("trace"));
            LogUtils.i("MainActivity.onActivityResult->:" + data.getStringExtra("referenceNo"));
            LogUtils.i("MainActivity.onActivityResult->:" + data.getStringExtra("orderNo"));
            LogUtils.i("MainActivity.onActivityResult->:" + data.getStringExtra("result"));
            LogUtils.i("MainActivity.onActivityResult->:" + data.getStringExtra("amount"));
            LogUtils.i("MainActivity.onActivityResult->:" + data.getStringExtra("authInfo"));
            LogUtils.i("MainActivity.onActivityResult->:" + data.getStringExtra("printInfo"));
            String result = data.getStringExtra("result");
            if (result.equals("00")) {
                mTrace = data.getStringExtra("trace");
                mAuthInfo = data.getStringExtra("authInfo");
                String referenceNo = data.getStringExtra("referenceNo");
                String cardNo = data.getStringExtra("cardNo");

                String printInfo = data.getStringExtra("printInfo");
                Gson gson = new Gson();
                PrintBean printBean = gson.fromJson(printInfo, PrintBean.class);
                mPhoneOrder = printBean.merchant_order;
                mPhoneMoney = mMoney;

                AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.this);
                builder.setTitle("交易成功");
                builder.setMessage("交易金额为：" + mMoney +
                        "\n流水号：" + mTrace +
                        "\n参考号：" + referenceNo +
                        "\n卡号：" + cardNo);
                builder.setPositiveButton("确定", new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        dialog.dismiss();

                    }
                });
                builder.show();
            } else {
                AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.this);
                builder.setTitle("交易失败");
                builder.setMessage("返回码为：" + result);
                builder.setPositiveButton("确定", new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        dialog.dismiss();

                    }
                });
                builder.show();
            }
        } else {
            Toast.makeText(this, "未做支付操作", Toast.LENGTH_SHORT).show();
        }
    }


    public void fenzhang(View view) {
        HaiNanTestActivity.launch(this);
    }
}
